package com.ruoyi.laiqianba.enums;

import cn.hutool.core.util.StrUtil;
import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Getter
public enum FlowRateTypeEnum {

    APIS("APIS", "全流程流量"),
    APIB("APIB", "半流程流量"),
    H5("H5", "H5表单流量"),
    APP("APP", "应用市场流量"),
    WX("WX","微信小程序流量"),
    ;

    private String value;
    private String name;

    FlowRateTypeEnum(String value, String name){
        this.value = value;
        this.name = name;
    }

    public static String getNameByValue(String value){
        for (FlowRateTypeEnum itemEnum: values()){
           if (StrUtil.equals(itemEnum.getValue(), value)){
               return itemEnum.getName();
           }
        }
        return value;
    }

    public static FlowRateTypeEnum getEntityByValue(String value){
        for (FlowRateTypeEnum itemEnum: values()){
           if (StrUtil.equals(itemEnum.getValue(), value)){
               return itemEnum;
           }
        }
        return null;
    }

    public static List<Map<String, String>> FlowRateTypeMapList(){
        List<Map<String, String>> resultList = new ArrayList<>();
        for (FlowRateTypeEnum flowRateTypeEnum : values()) {
            Map<String, String> itemMap = new HashMap<>();
            itemMap.put("key", flowRateTypeEnum.getName());
            itemMap.put("value", String.valueOf(flowRateTypeEnum.getValue()));
            resultList.add(itemMap);
        }
        return resultList;
    }

    public static List<Map<String, Object>> getShowMap(){
        List<Map<String, Object>> resultList= new ArrayList<>();
        for (FlowRateTypeEnum itemEnum: values()){
            Map<String, Object> itemMap = new HashMap<>();
            itemMap.put("value", itemEnum.getValue());
            itemMap.put("name", itemEnum.getName());
            resultList.add(itemMap);
        }
        return resultList;
    }

}
